package com.tank.factory;

import com.almasb.fxgl.core.math.FXGLMath;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.EntityFactory;
import com.almasb.fxgl.entity.SpawnData;
import com.almasb.fxgl.entity.Spawns;
import com.tank.constant.GameType;
import com.tank.constant.ItemType;

import java.util.Locale;

public class ItemEntityFactory implements EntityFactory {

    @Spawns("item")
    public Entity newItem(SpawnData data) {
        ItemType itemType = FXGLMath.random(ItemType.values()).get();
//        ItemType itemType = FXGLMath.random(new ItemType[]{ItemType.SHIP}).get();
        data.put("itemType", itemType);
        return FXGL.entityBuilder(data)
                .type(GameType.ITEM)
                .viewWithBBox("item/" + itemType.toString().toLowerCase(Locale.ROOT) + ".png")
                .collidable()
                .build();
    }
}
